# def send_message(phone, content):
#     """发送消息"""
#     pass
#
# def send_image(img_path, content):
#     """发送图片"""
#     pass
#
#
# def send_emoji(emoji):
#     """发送表情"""
#     pass
#
#
# def send_file(path):
#     """发送文件"""
#     pass
#
#
# function_dict = {
#     "1": [send_message, ['15131255089', '你好呀']],
#     "2": [send_image, ['xxx/xxx/xx.png', '消息内容']],
#     "3": [send_emoji, ["😁"]],
#     "4": [send_file, ['xx.zip']]
# }
#
# print("欢迎使用xx系统")
# print("请选择：1.发送消息；2.发送图片；3.发送表情；4.发送文件")
# choice = input("输入选择的序号：")  # 1
#
# item = function_dict.get(choice)  # [ send_message,  ['15131255089', '你好呀']],
# if not item:
#     print("输入错误")
# else:
#     # 执行函数
#     func = item[0]  # send_message
#     param_list = item[1]  # ['15131255089', '你好呀']
#
#     func(*param_list)
# # send_message(*['15131255089', '你好呀']),动态传参将参数打散开

#函数名赋值
# def func(a1,a2):
#     print(a1,a2)
#
# new_fuc = func
#
# # 此时，new_fuc和func都代指上面的那个函数，所以都可以被执行。
# func(1,1)
# new_fuc(2,2)
# def func(a1,a2):
#     print(a1,a2)
#
# # 执行func函数
# func(11,22)
#
# # func重新赋值成一个字符串
# func = "小峰"
#
# print(func)

#函数名做参数和返回值，即函数中可以调用函数
# def plus(num):
#     return num + 100
#
# def handler(func):
#     res = func(10)  # 110
#     msg = "执行func，并获取到的结果为:{}".format(res)
#     print(msg)  # 执行func，并获取到的结果为:110
#
# # 执行handler函数，将plus作为参数传递给handler的形式参数func
# handler(plus)


# def plus(num):
#     return num + 100
#
#
# def handler():
#     print("执行handler函数")
#     return plus
#
# result = handler()
# data = result(20)  # 120
# print(data)


#函数作用域

def func():
    name = "小峰"
    data_list = [11,22,33,44]
    print(name,data_list)
    age = 20#局部变量，局部变量优先原则
    print(age)

def handler():
    print(age)

age=5#全局变量
func()
handler()
print(age)
